package com.thiswhyme.vc.core;

import org.springframework.util.StringUtils;

/**
 * Created by thiswhyme on 2021-01-18.
 */
public class ApiConverter {

    public static ApiItem convert(String api) {
        ApiItem apiItem = new ApiItem();
        if (StringUtils.isEmpty(api)) {
            return apiItem;
        }

        String[] cells = api.split("\\.");
        apiItem.setHigh(Integer.parseInt(cells[0]));
        if (cells.length > 1) {
            apiItem.setMid(Integer.parseInt(cells[1]));
        }

        if (cells.length > 2) {
            apiItem.setLow(Integer.parseInt(cells[2]));
        }

        return apiItem;
    }

}